package dao.Impl;

import dao.CollegeDao;
import po.College;
import util.DBUtils;
import util.DaoRepeat;

import java.sql.SQLException;
import java.util.List;

public class CollegeDaoImpl   extends BaseDaoImpl<College> implements CollegeDao {
    @Override
    public List<College> queryAllCollege() {
        List<College> colleges = queryMany("select * from College", College.class, null);
        return  colleges;
    }

    @Override
    public boolean delete(College college) {
        try {
            delete(college, DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }return true;
    }

    @Override
    public boolean insert(College college)  {
        try {
            insert(college,DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }return true;
    }

    @Override
    public boolean update(College college) {
        try {
            update(college,DBUtils.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
        }return  true;
    }

    @Override
    public College queryOne(Integer id) {
        College college = queryOne("select * from College where id=?", College.class, id);
        return college;
    }
}
